import express from 'express';
const router = express.Router();

router.get('/user', async (req, res, next) => {
    const wechatRobot = req.app.locals.wechatRobot;
    try {
        const wxUser = await wechatRobot.getWxUser(req.context.accountNo);
        res.json({
            success: true,
            message: '',
            data: {
                source: wxUser,
                name: wxUser.nick,
                avatarUrl: wxUser.avatarMinUrl || `https://sg-funds-center.oss-cn-hangzhou.aliyuncs.com/funds/gpt/${wxUser.wxid}.jpg`,
            }
        });
    } catch (err) {
        console.error('获取用户信息失败', err);
        res.json({
            success: true,
            message: '从微信端获取用户信息为空',
            data: null
        });
    }
});

export default router;